/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.merak.core.model.parameter;

import java.util.regex.Pattern;

public abstract class Parameters {

	//~ Attributes /////////////////////////////////////////////////////////////////////////////////
	//**********************************************************************************************
	public static final Pattern EMAIL        = Pattern.compile("^[\\w\\.-]+@([\\w\\-]+\\.){1,3}[A-Z]{2,4}$",Pattern.CASE_INSENSITIVE);
	public static final Pattern NUMERIC      = Pattern.compile("[0-9]*");
	public static final Pattern ALPHA        = Pattern.compile("[A-Z]*",Pattern.CASE_INSENSITIVE);
	public static final Pattern ALPHANUM     = Pattern.compile("[A-Z0-9]*",Pattern.CASE_INSENSITIVE);
	public static final Pattern PERSONALNAME = Pattern.compile("[A-ZÁÉÍÓÚÂÊÔÃÕ]('[A-ZÁÉÍÓÚÂÊÔÃÕ])?[a-zàáéíóúâêôãõ]+([ \\-]([a-zàáéíóúâêôãõ]{2,3} )?[A-ZÁÉÍÓÚÂÊÔÃÕ]('[A-ZÁÉÍÓÚÂÊÔÃÕ])?[a-zàáéíóúâêôãõ]+)*");
	public static final Pattern CPF          = Pattern.compile("([0-9]{3}\\.[0-9]{3}\\.[0-9]{3})-([0-9]{2})");
	public static final Pattern CNPJ         = Pattern.compile("([0-9]{2}\\.[0-9]{3}\\.[0-9]{3})/([0-9]{4})-([0-9]{2})");
	public static final Pattern RG           = Pattern.compile("([0-9]{7})-([0-9]{1})");
	
	//~ Methods ////////////////////////////////////////////////////////////////////////////////////
	//**********************************************************************************************	
	public static void notNull(String paramName,Object paramValue) {
		
		if (paramValue == null) throw new IllegalArgumentException(
			"The parameter, argument or property '"+paramName+"' cannot be null"
		);
		
	}
	//**********************************************************************************************
	public static void notBlank(String paramName,String paramValue) {
		
		if (paramValue == null) throw new IllegalArgumentException(
			"The parameter, argument or property '"+paramName+"' cannot be null"
		);
		if (paramValue.isEmpty()) throw new IllegalArgumentException(
			"The parameter, argument or property '"+paramName+"' cannot be empty"
		);		
		
	}
	//**********************************************************************************************	

}
